home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR10 / SBF3.ZIP / SBP_CHK.ASM < prev    next >
Assembly Source File  |  1993-09-19  |  1KB  |  78 lines

  1. ; Reset routine for Soundblaster
  2. ; Coded for the SBF by millerje
  3. ; Modified (to replace sbp.asm) by cmb.
  4.  
  5. DSP_RESET    equ    6
  6. DSP_DATA_AVAIL    equ    0Eh
  7. DSP_READ_DATA    equ    0Ah
  8.  
  9.         .MODEL    large,C
  10.  
  11.         .DATA
  12. PUBLIC SbIOaddr, SbIRQ, SbDMAchan, SbType
  13.  
  14. SbIOaddr  dw      220h
  15. SbIRQ      dw      7
  16. SbDMAchan dw      1
  17. SbType      dw      2
  18.  
  19.         .CODE
  20.         PUBLIC    Sb_Init
  21. Sb_Init        PROC
  22.  
  23. ; Reset the DSP by sending 1, (delay), then 0
  24.         mov    al,1
  25.         mov    dx,[SbIOaddr]
  26.         add    dx,DSP_RESET
  27.         out    dx,al
  28.  
  29. ; Do a wait for I/O (each bus access takes 1 microsecond on a standard ISA)
  30. ; Must be at least 3.3 microseconds
  31.         in    al,dx
  32.         in    al,dx
  33.         in    al,dx
  34.         in    al,dx
  35.  
  36.         mov    al,0
  37.         mov    dx,[SbIOaddr]
  38.         add    dx,DSP_RESET
  39.         out    dx,al
  40.  
  41.         mov    cx,64h
  42. DataWait:
  43.         mov    dx,[SbIOaddr]
  44.         add    dx,DSP_DATA_AVAIL
  45.         in    al,dx
  46.         test    al,80h
  47.         jnz    YesData            ;a byte is waiting...
  48.         loop    DataWait
  49.  
  50. ; Timed out- there's no data there
  51.         jmp    short exit
  52.  
  53. ; Data is waiting, if = 0AAh, there's a SB here!
  54. YesData:
  55.         mov    dx,[SbIOaddr]
  56.         add    dx,DSP_READ_DATA
  57.         in    al,dx
  58.         cmp    al,0AAh
  59.         je    YepSB            ;Found the ID byte
  60.         loop    DataWait        ;No, wait for next byte
  61.  
  62. ; timed out- can't find signature
  63.         jmp    short exit
  64.  
  65. YepSB:
  66.         mov    ax,0
  67.         ret
  68.  
  69. exit:
  70.         mov    ax,1
  71.         ret
  72.  
  73. Sb_Init        ENDP
  74.  
  75.         END
  76.  
  77.  
  78.